import { createRouter, createWebHistory } from "vue-router";
import type { RouteRecordRaw } from "vue-router";
export const Layout = () => import("@/layouts/index.vue");

export const homeRoutes: RouteRecordRaw = {
  path: "/home",
  name: "home",
  component: () => import("@/views/home/index.vue"),
  meta: {
    title: "首页",
    hidden: false,
    icon: "icon-ic_menu_home",
    menuType: "M", // C菜单，M 目录
    isCache: "1", // 0 缓存，1 不缓存
  },
};

export const staticRoutes: RouteRecordRaw[] = [
  {
    path: "/login",
    component: () => import("@/views/login/index.vue"),
    meta: {
      title: "登录",
    },
  },
  {
    path: "/",
    name: "rootPath",
    redirect: "/home",
    component: Layout,
    children: [homeRoutes],
  },
  {
    path: "/:pathMatch(.*)*",
    name: "error",
    component: () => import("@/layouts/exception/error.vue"),
    meta: {
      title: "找不到页面",
    },
  },
];

const router = createRouter({
  routes: [...staticRoutes],
  history: createWebHistory("/"),
});

export default router;
